const { DataTypes } = require('sequelize');
const sequelize = require('../config/database')

const SceneryModel = sequelize.define('Scenery', {
  scenery_id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    allowNull: false
  },
  province_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  city_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  name: {
    type: DataTypes.STRING,
    allowNull: false
  },
  address: {
    type: DataTypes.STRING,
    allowNull: false
  },
  description: {
    type: DataTypes.STRING,
    allowNull: false
  },
  images: {
    type: DataTypes.JSON,
    allowNull: false
  },
  longitude: {
    type: DataTypes.DECIMAL(9, 6),
    allowNull: false
  },
  latitude: {
    type: DataTypes.DECIMAL(9, 6),
    allowNull: false
  },
  opening_time: {
    type: DataTypes.STRING,
    allowNull: false
  },
  price: {
    type: DataTypes.DECIMAL(10, 2),
    allowNull: false
  },
  rating: {
    type: DataTypes.DECIMAL(3, 1),
    allowNull: false
  },
  phone: {
    type: DataTypes.STRING,
    allowNull: false
  },
  grade: {
    type: DataTypes.ENUM('5A', '4A', '3A', '2A', '1A', '普通景点'),
    allowNull: false
  },
  type: {
    type: DataTypes.ENUM('城市观光', '人文古迹', '自然风光', '网红打卡', '展览展馆'),
    allowNull: false
  },
  introduce: {
    type: DataTypes.TEXT,
    allowNull: false
  },
  preferential_policy: {
    type: DataTypes.TEXT,
    allowNull: false
  },
  tips: {
    type: DataTypes.TEXT,
    allowNull: false
  },
  traffic: {
    type: DataTypes.TEXT,
    allowNull: false
  },
  is_hot: {
    type: DataTypes.TINYINT,
    defaultValue: 0,
    allowNull: false
  }
}, {
  freezeTableName: true,
  tableName: 'scenery',
  timestamps: false
})

module.exports = SceneryModel